package com.example.canteen.controller;

import com.example.canteen.Response;
import com.example.canteen.dto.OrderDTO;
import com.example.canteen.dto.PrivateRoomDTO;
import com.example.canteen.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    OrderService orderService;

    @PostMapping("/add")
    public Response<Long> addOrder(@RequestBody OrderDTO orderDTO) {
        return Response.newSuccess(orderService.addOrder(orderDTO));
    }

    @PostMapping("/all")
    public Response<Set<OrderDTO>> getAllOrder() {
        return Response.newSuccess(orderService.getAllOrders());
    }

    @PostMapping("/update")
    public Response<OrderDTO> updateOrder(@RequestBody OrderDTO orderDTO) {
        return Response.newSuccess(orderService.updateOrder(orderDTO.getId(), orderDTO.getName(), orderDTO.getDate(), orderDTO.getPrivateRoomName(), orderDTO.getDishCount(), orderDTO.getSetMealCount()));
    }
}
